<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
    <title>地图导航</title>
    <style>
      * {
        margin: 0;
        padding: 0px;
      }
      html,
      body,
      #container {
        width: 100%;
        height: 100%;
        background-color: #ccc;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>
    <script type="text/javascript">
      window._AMapSecurityConfig = {
        securityJsCode: '2c45f22bb70bb2d9339020a88986c972'
      }
    </script>
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=a74729742a196214e01697e3aa6a699c"></script>
    <script type="text/javascript">
      var map = new AMap.Map('container', {
        viewMode: '3D', // 默认使用 2D 模式，如果希望使用带有俯仰角的 3D 模式，请设置 viewMode: '3D'
        zoom: 18, // 初始化地图层级
        center: [114.227696, 22.726783] // 初始化地图中心点
      })

      function beginDriving(start, end) {
        AMap.plugin(['AMap.Driving'], function () {
          const driving = new AMap.Driving({
            map: map,
            policy: AMap.DrivingPolicy.LEAST_TIME
          })
          const points = [{ keyword: start }, { keyword: end }]
          driving.search(points, function (status, result) {
            if (status === 'complete') {
              console.log('绘制驾车路线完成')
            } else {
              console.log('获取驾车数据失败：' + result)
            }
          })
        })
      }
    </script>
  </body>
</html>
